<?php
namespace Library\Config;

class Ini
{
	private $_config;
	
	public function __construct($filename)
	{
		$this->_config = $this->_fixIni(parse_ini_file($filename, true));
	}
	
	private function _fixIni($ini_array)
	{
		$new_array = array();
								
		foreach($ini_array as $key => $value)
		{
			if (strpos($key, '.') !== false)
			{
				$parts = explode('.', $key);				
				$new_array[$parts[0]][$parts[1]] = $value;
			}
			else if (is_array($value))
			{
				$new_array[$key] = $this->_fixIni($value);
			}
			else
			{
				$new_array[$key] = $value;
			}
		}
		
		return $new_array;
	}
	
	public function getData()
	{
		return $this->_config;
	}
}
